{include file="public/_header.html"}
	
<body style="margin:0px auto 0px; auto; padding:0px;">
<div id="main-body"></div>
<div id="outer" style="cursor:default; margin:0px auto 0px auto; padding:0px; width:98%;">
<div class="mainmenu5" style="padding:8px;font-size:12pt;letter-spacing:2px;">
	<b>{language text='Mod_Chat.live_chat'}</b>
</div>

{if $bMembersLimit}

	<table class="border2" style="width:100%;" cellpadding="4" cellspacing="0">
	<tr>
		<td style="font-size:9pt;" class="color">
		<br/><br/><br/>
		{language text='Mod_Chat.ChatFullTryLater'}
		<br/><br/><br/>
		</td>
	</tr>
	</table>
</div>

{else}

<table class="border2" style="width:100%;" cellpadding="4" cellspacing="0">
<tr>
	<td style="font-size:9pt;" class="color">

	<form method="post" action="{url link='public.account.livechat'}">
	<b>{language text='Mod_Chat.rooms'}:</b>
	<select name="roomid" style="width:200px;" onchange="submit();">
	<option value="1">{language text='Mod_Chat.select'}</option>
	{foreach from=$aRooms item=aRoom}
		<option value="{$aRoom.roomid}"{if $iRoomId == $aRoom.roomid} selected="selected"{/if}>{$aRoom.name}</option>
	{/foreach}
	</select>
	</form>

	<table style="width:100%; height:300px;" cellpadding="0" cellspacing="4" border="0">
	<tr>
	<td style="width:75%; vertical-align:top;" class="border2">
		<div id="chat_content_div" style="overflow:auto; height:298px;">
			<div id="fullchat">{$sChatContent}</div>
		</div>
	</td>
	<td style="width:25%; vertical-align:top;" class="border2">
		<div class="mainmenu5" style="padding:8px;">
			<img src="{$sStylePath}spacer.gif" class="sqr" style="vertical-align:middle;" alt="" width="7" height="7" />
			<span style="vertical-align:middle;"><b>{language text="whos_chatting"}</b></span>
		</div>
		<div id="onlineuser" style="overflow:auto; height:298px;">{$sWhosOnline}</div>
	</td>
	</tr>
	</table>

    <form style="padding:0px; margin:0px;" id="signupForm" action="javascript:void(null);" onsubmit="submitSignup();">
    <input id="user" name="user" value="{$aCurrUser.user}" type="hidden" />
    <input id="typeF" name="typeF" value="full" type="hidden" />
	<table style="width:100%;">
	<tr>
		<td colspan="2">
		{include file="$sSmartyTemplateDir/_blocks/smilies.html"}
		</td>
	</tr>
	<tr>
		<td>
		<textarea cols="60" rows="9" style="width:98%;" id="maintext" name="sTxt" onkeyup="return (!entsub(event)) ? false : entsub(event);"></textarea>
		</td>
		<td>
		<input type="button" value="{language text='Mod_Chat.send'}" style="cursor:pointer;" id="submitButton" onclick="submitAjaxForm()" />
		</td>
	</tr>
	</table>
	</form>

	</td>
</tr>
</table>
</div>
<script type="text/javascript">window.setInterval("xajax_getOnlineUser('{$iRoomId}')", 7000);</script>
<script type="text/javascript">window.setInterval("xajax_getChatText('1', '{$iRoomId}')", 5000);</script>
<script type="text/javascript">
{literal}

document.getElementById('chat_content_div').scrollTop = document.getElementById('chat_content_div').scrollHeight;

function submitAjaxForm()
{
	tinyMCE.triggerSave(false, false);
	tinyMCE.execCommand('mceSetContent',false, '');
	{/literal}
	xajax_processForm(xajax.getFormValues("signupForm"), {$iRoomId});
	{literal}
	return false;
}

function entsub(event)
{
	var Key = event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode);

	if (Key == 13)
	{
		submitAjaxForm();
		return false;
	}
	else
	{
        return true;
	}
}

{/literal}
</script>
{/if}
</body>
</html>